const mongoose = require('../db')

var bill = new mongoose.Schema({
    user_id:{//用户id
        type:Number,
        required:true,
        index:true
    },
    b_id:{//账单id
        type:Number,
        required:true,
        index:true
    },
    addTime:{
        type:String,
        required:true,
    },
    time_for_week:{
        type:String,
        required:true,
    },
    addDate:{//添加时间
        type:Date,
        required:true,
        index:true
    },
    desc:String,//备注
    amount:{//金额
        type:Number,
        required:true,
        set(e){
            return Number(e).toFixed(2)
        }
    },
    bill_type:{//类型，1为支出，2为收入
        type:Number,
        required:true
    },
    class_id:{
        type:Number,
        required:true,
    },
    at_year:{//订单年份
        type:String,
        index:true
    },
    at_month:{//订单月份
        type:String,
    },
    at_week:{//订单所在周
        type:String,
    },
    at_day:{//订单所在日
        type:String,
    },
})

module.exports = mongoose.model('bill',bill)

